package ynu.edu.Dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import ynu.edu.Entity.Camera;

import java.util.Date;
import java.util.List;

public interface CameraDao extends JpaRepository<Camera,Long> {
    @Query("SELECT c FROM Camera c JOIN FETCH c.device JOIN FETCH c.device.greenhouse WHERE c.createTime >= :oneMonthAgo ORDER BY c.createTime DESC")
    List<Camera> findCamerasCreatedInLastMonth(@Param("oneMonthAgo") Date oneMonthAgo);

}
